class Person {

    name: string;

    age: number;

    // 类的成员变量（属性），可以给默认值
    sex: string = "男";

    // 构造方法签名1
    constructor(name:string,age:number,sex:string);

    // 构造方法签名2
    constructor(name:string,age:number);

    constructor(name:string,age:number,sex?:string) {
        this.name = name;
        this.age = age;
        if (sex) {
            this.sex = sex;
        }
    }

    sayHello():void {
        console.log(this.name + "，向大家问好！")
    }
}

// 创建类的示例
let lbj = new Person("罗佰君",26,"男");
let fx = new Person("奉先",35);

console.log(lbj);
console.log(fx);

lbj.sayHello();
fx.sayHello();